package com.example.smartlearning.controller;

import com.example.smartlearning.service.impl.MailServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;


@CrossOrigin//跨域
@RestController//遵循RestFul
@RequestMapping("/Smart/Send/")
public class SendVerifyController {

    @Resource
    MailServiceImpl mailService;

    /**
     * 发送随机验证码
     *
     * @param to 邮箱
     * @return 返回
     */
    @RequestMapping("/sendRoundTextMailMessage")
    public String sendRoundTextMailMessage(@RequestParam("to") String to) {
        return mailService.sendRoundTextMailMessage(to);
    }

    /**
     * 传入手机号发送验证码
     *
     * @param phone 手机号
     * @return 返回
     */
    @RequestMapping("/SendSms")
    public String SendSms(@RequestParam("phone") String phone) {
        return mailService.SendSms(phone);
    }

    /**
     * 验证验证码
     *
     * @param account 账号
     * @param code 验证码
     * @return 返回
     */
    @PostMapping("checkCode")
    public String checkCode(@RequestParam("account") String account, @RequestParam("code") String code) {
        return mailService.checkCode(account, code);
    }
}
